import ZhToPinYin from '../../../components/common/tui-zh-pinyin/tui-zh-pinyin.js';
Page({
  data: {
    zhToPinYin: null,
    chinese: "欢迎使用组件库，希望大家多多支持！",
    pinyinSpace: "", //拼音带空格
    pinyin: "", //拼音不带空格
    initials: "", //首字母
    surname: ["赵", "钱", "孙", "李", "周", "吴", "郑", "王", "曾", "单", "查", "尉", "晟"],
    surnamePy: [],
    polyphone: ""
  },
  onLoad: function (options) {
    //titleCase：首字母是否大写 ,默认true
    this.data.zhToPinYin = new ZhToPinYin(true);

    let pyArr = []
    for (let item of this.data.surname) {
      let pinyin = this.data.zhToPinYin.surnamePolyphone(item)
      pinyin = pinyin ? pinyin : this.data.zhToPinYin.getPinYin(item)
      pyArr.push(pinyin)
    }

    this.setData({
      pinyinSpace:this.data.zhToPinYin.getPinYin(this.data.chinese, true),
      pinyin:this.data.zhToPinYin.getPinYin(this.data.chinese, false),
      initials:this.data.zhToPinYin.getInitials(this.data.chinese),
      surnamePy:pyArr,
      polyphone:JSON.stringify(this.data.zhToPinYin.getInitials("单", true))
    })
  },
  onShareAppMessage: function () {

  }
})